package com.eos.orm.mybatis.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.eos.orm.mybatis.dao.SysRoleMapper;
import com.eos.orm.mybatis.model.SysRole;
import com.eos.orm.mybatis.model.SysRoleExample;
/**
 * sys_role系统角色表的CURD操作
 * @author sz
 *
 */
public class SysRoleMapperImpl extends AbstractSqlSessionFactory implements
		SysRoleMapper {

	public int countByExample(SysRoleExample example) {
		return 0;
	}

	public int deleteByExample(SysRoleExample example) {
		return 0;
	}

	public int deleteByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysRoleMapper mapper = session.getMapper(SysRoleMapper.class);
			mapper.deleteByPrimaryKey(id);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysRoleMapperImpl.deleteByPrimaryKey throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insert(SysRole record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysRoleMapper mapper = session.getMapper(SysRoleMapper.class);
			mapper.insert(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysRoleMapperImpl.insert throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insertSelective(SysRole record) {
		return 0;
	}

	public List<SysRole> selectByExample(SysRoleExample example) {
		List<SysRole> templist = new ArrayList<SysRole>();
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysRoleMapper mapper = session.getMapper(SysRoleMapper.class);
			templist = mapper.selectByExample(example);
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysRoleMapperImpl.selectByExample throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return templist;
	}

	public SysRole selectByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysRoleMapper mapper = session.getMapper(SysRoleMapper.class);
			return mapper.selectByPrimaryKey(id);
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysRoleMapperImpl.selectByPrimaryKey throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return null;
	}

	public int updateByExample(SysRole record, SysRoleExample example) {
		return 0;
	}

	public int updateByExampleSelective(SysRole record, SysRoleExample example) {
		return 0;
	}

	public int updateByPrimaryKey(SysRole record) {
		return 0;
	}

	public int updateByPrimaryKeySelective(SysRole record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysRoleMapper mapper = session.getMapper(SysRoleMapper.class);
			mapper.updateByPrimaryKeySelective(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysRoleMapperImpl.updateByPrimaryKeySelective throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

}
